package tcp;

import java.net.*;
import java.io.*;

public class CheckInput {
    public static void main(String[] args) {
        String dataGot = null;
        try {
            ServerSocket skt = new ServerSocket(3333);
            while (true) {
                Socket client = skt.accept();
                BufferedReader bfReader = new BufferedReader(new InputStreamReader(client.getInputStream()));
                PrintWriter bfWriter = new
                        PrintWriter(new BufferedWriter(new OutputStreamWriter(client.getOutputStream())), true);

                System.out.println("读取数据");
                dataGot = bfReader.readLine();

                System.out.println("读取成功\t" + dataGot);

                System.out.println("开始写应答");
                bfWriter.println(dataGot);
                System.out.println("应答已写完");

                bfReader.close();
                bfWriter.close();
                client.close();
            }
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
}
